package shop.common.core;

import lombok.Data;

@Data
public class Result {

    private Integer code;

    private String msg;

    private Object data;

    private Result() {
    }

    public static Result ok() {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("success");
        return result;
    }

    public static Result fail() {
        Result result = new Result();
        result.setCode(400);
        result.setMsg("failure");
        return result;
    }

    public Result data(Object data) {
        this.setData(data);
        return this;
    }

    public Result msg(String msg) {
        this.setMsg(msg);
        return this;
    }

    public Result code(Integer code) {
        this.setCode(code);
        return this;
    }
}
